package com.ymm.controller;

import com.ymm.domain.entity.Exam;
import com.ymm.domain.vo.ResponseResult;
import com.ymm.enums.AppHttpCodeEnum;
import com.ymm.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 椰咩咩咩
 * @version 1.0-SNAPSHOT
 * @date 2023/4/10 21:42
 * @Description
 */
@RestController
@RequestMapping("/exam")
public class ExamController {

    @Autowired
    private ExamService examService;

    @GetMapping("/list")
    public ResponseResult getExamList() {
        return examService.getExamList();
    }

    @PreAuthorize("@ps.hasPermission('student:exam:add')")
    @PostMapping("/add")
    public ResponseResult addExam(@RequestBody Exam exam) {
        return examService.addExam(exam);
    }

    @PreAuthorize("@ps.hasPermission('student:exam:update')")
    @PutMapping("/update")
    public ResponseResult updateExam(@RequestBody Exam exam) {
        examService.updateById(exam);
        return ResponseResult.okResult();
    }

    @PreAuthorize("@ps.hasPermission('student:exam:height')")
    @GetMapping("/hw")
    public ResponseResult getHW() {
        return examService.getHW();
    }
}
